home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/env python
-
- ###########################
- # Awn-notif python script #
- ###########################
-
- import sys
- import dbus
- import os
-
- # Args :
- #sys.argv[1] -> number of new mail (0 remove the message)
- #sys.argv[2] -> message to display (%i is the number of unread mails)
-
- # Get the unread mail number
- if len(sys.argv) < 2:
- mail_number = 0
- else:
- mail_number = int(sys.argv[1])
-
- # Get the message to display
- if len(sys.argv) < 3:
- msg = '%i new mails'
- else:
- msg = sys.argv[2]
-
- # Get awn
- bus = dbus.SessionBus()
- obj = bus.get_object("com.google.code.Awn", "/com/google/code/Awn")
- awn = dbus.Interface(obj, "com.google.code.Awn")
-
- # Switch the awn info
- if mail_number > 0:
- awn.SetInfoByName ("thunderbird", msg % mail_number)
- else:
- awn.UnsetInfoByName ("thunderbird")
-
- # Switch the ASUS led
- if mail_number == 0:
- os.system('echo 0 > /proc/acpi/asus/mled')
- else:
- os.system('echo 1 > /proc/acpi/asus/mled')
-